<form method="post" id="busca">
    <p id="globalSearch">
        <label for="globalSearch">Buscar Arquivo</label>
        <input type="text" name="globalSearch" id="search"/>
        <button type="submit" name="doGlobalSearch">Buscar</button>
    </p>
</form>

<ul>
    <li>
        <span class="usuario">Usuário</span>
        <ul>
            <li><a href="/home/index" ajax="✓">Início</a></li>
            <li><a href="<?php echo $this->url(array('controller' => 'auth', 'action' => 'logout')); ?>">Sair</a></li>
        </ul>
    </li>
    <li>
        <span class="usuario">Repositório</span>
    </li>
</ul>

<ul class="pastas" >
</ul>

<script type="text/javascript">
    $(function(){
        $("form#busca").submit(function(e) {
            e.preventDefault();
            var old_busca = (new String(window.location)).split('resultados/')[1];
            var new_busca = $('#search').val().replace(/ /g,"_");
            if (old_busca != new_busca) {
                $.ajax({
                    type: "POST",
                    url: "busca/search",
                    data: "fname="+ new_busca,
                    success: function(e){
                        if (e) {
                            window.location = caracter + "busca/resultados/" + new_busca;
                            $( "#dialog" ).dialog( "open" );
                            return false;
                        }
                    }
                });
            }
            return false;
        });
    });

    $( function() {
        $('.pastas').fileTree({
            script: 'ajax/getfolders'
        }, function(file) {
            alert(file);
        });
    });
</script>